/**
 * Created by lvjiaxuan on 2016/11/24.
 */
$(document).ready(function () {
    function screenAdapter(x) {
        /*alert($(document).height());*/
        $('aside').height($(window).height() - x);
        $('article').height($(window).height() - x);
    }
    if (window.innerWidth < 600) {
    	screenAdapter(100);
    	$('aside').hide();
    	document.body.onclick = function() {
    		$('aside').hide();
    	}
    	console.log(window.frames['mainFrame'].location.href);
    	$('aside').unbind('click').click(function() {
    		setTimeout(function() {
    			if (window.frames['mainFrame'].location.href != "about:blank") {
        			$('aside').hide();
        		}
    		}, 1000);
    	});
    } else {
    	screenAdapter(100);
    	document.body.onclick = null;
    }
    
    window.onresize = function(){
    	if (window.innerWidth < 600) {
    		screenAdapter(100);
        	$('aside').hide();
        	document.body.onclick = function() {
        		$('aside').hide();
        	}
        	$('aside').unbind('click').click(function() {
        		setTimeout(function() {
        			if (window.frames['mainFrame'].location.href != "about:blank") {
            			$('aside').hide();
            		}
        		}, 1000);
        	});
        } else {
        	screenAdapter(100);
        	$('aside').show();
        	document.body.onclick = null;
        }
    }
    
	$('.show').click(function(e) {
		$('aside').toggle();
		e.stopPropagation();
	});
	$('aside').click(function(e) {
		e.stopPropagation();
	});
});